<template>
  <view @click="chooseImage">
    <slot name="content"></slot>
  </view>
</template>

<script setup lang="ts">

import {uploadFile} from '/settings'
import {defineEmits, ref} from "vue";



const emits =defineEmits(['onSelect'])
const url = uploadFile.url
const name = uploadFile.name

const image = ref()
const chooseImage = () => {
  uni.chooseImage({
    count: 1,
    success: (res) => {
      uni.uploadFile({
        url: url,
        filePath: res.tempFilePaths[0],
        name: name,
        success: (uploadFileRes) => {
          let tmp = JSON.parse(uploadFileRes.data).data
          console.log(res)
          image.value = tmp
          emits('onSelect',tmp,res.tempFiles[0]?.size)
        }
      });
    }
  });
}
</script>

<style scoped>

</style>